package com.hsytech.dijiebao.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferencesTools {
	public static void writeEmail(Context context, String token) {
		SharedPreferences sp = context.getSharedPreferences(Constants.COMMON_TOKEN, Context.MODE_PRIVATE);
		SharedPreferences.Editor ed = sp.edit();
		ed.putString(Constants.EMAIL, token);
		ed.commit();
	}

	public static String getEmail(Context context) {

		String result = "";
		SharedPreferences sp = context.getSharedPreferences(Constants.COMMON_TOKEN, Context.MODE_PRIVATE);
		result = sp.getString(Constants.EMAIL, "");

		return result;
	}

	public static void writeToken(Context context, String token) {
		SharedPreferences sp = context.getSharedPreferences(Constants.COMMON_TOKEN, Context.MODE_PRIVATE);
		SharedPreferences.Editor ed = sp.edit();
		ed.putString(Constants.TOKEN, token);
		ed.commit();
	}

	public static String getTOKEN(Context context) {

		String result = "";
		SharedPreferences sp = context.getSharedPreferences(Constants.COMMON_TOKEN, Context.MODE_PRIVATE);
		result = sp.getString(Constants.TOKEN, "");

		return result;
	}

	public static void writeUid(Context context, String token) {
		SharedPreferences sp = context.getSharedPreferences(Constants.COMMON_UID, Context.MODE_PRIVATE);
		SharedPreferences.Editor ed = sp.edit();
		ed.putString(Constants.UID, token);
		ed.commit();
	}

	public static String getUid(Context context) {

		String result = "";
		SharedPreferences sp = context.getSharedPreferences(Constants.COMMON_UID, Context.MODE_PRIVATE);
		result = sp.getString(Constants.UID, "");

		return result;
	}

	public static void writeRongToken(Context context, String token) {
		SharedPreferences sp = context.getSharedPreferences(Constants.COMMON_RONG_TOKEN, Context.MODE_PRIVATE);
		SharedPreferences.Editor ed = sp.edit();
		ed.putString(Constants.RONG_TOKEN, token);
		ed.commit();
	}

	public static String getRongToken(Context context) {

		String result = null;
		SharedPreferences sp = context.getSharedPreferences(Constants.COMMON_RONG_TOKEN, Context.MODE_PRIVATE);
		result = sp.getString(Constants.RONG_TOKEN, "");

		return result;
	}

	// ��ע����

	public static void writeCityID(Context context, String cityID) {
		SharedPreferences sp = context.getSharedPreferences(Constants.COMMON_CITY_ID, Context.MODE_PRIVATE);
		SharedPreferences.Editor ed = sp.edit();
		ed.putString(Constants.CITY_ID, cityID);
		ed.commit();
	}

	public static String getCityID(Context context) {

		String result = "";
		SharedPreferences sp = context.getSharedPreferences(Constants.COMMON_CITY_ID, Context.MODE_PRIVATE);
		result = sp.getString(Constants.CITY_ID, "");

		return result;
	}

	public static void writeCityName(Context context, String cityNmae) {
		SharedPreferences sp = context.getSharedPreferences(Constants.COMMON_CITY_NAME, Context.MODE_PRIVATE);
		SharedPreferences.Editor ed = sp.edit();
		ed.putString(Constants.CITY_NAME, cityNmae);
		ed.commit();
	}

	public static String getCityName(Context context) {

		String result = "";
		SharedPreferences sp = context.getSharedPreferences(Constants.COMMON_CITY_NAME, Context.MODE_PRIVATE);
		result = sp.getString(Constants.CITY_NAME, "");

		return result;
	}

}
